//package zengjin.test;
//
//import io.swagger.v3.oas.annotations.tags.Tag;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.fileupload.FileItem;
//import org.apache.commons.fileupload.FileItemFactory;
//import org.apache.commons.fileupload.RequestContext;
//import org.apache.commons.fileupload.servlet.ServletFileUpload;
//import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.BufferedOutputStream;
//import java.io.File;
//import java.util.List;
//
///**
// * @author 19324
// */
//@Tag(name = "文件相关接口")
//@RestController
//@RequestMapping("/fragmentFile")
//@Slf4j
//public class FragmentFileController {
//
//    private static final String FILE_PATH = "D:\\test\\update";
//
//    private static final String utf8 = "utf-8";
//
//    @RequestMapping("/upload")
//    @ResponseBody
//    public String upload(HttpServletRequest request, HttpServletResponse response) throws Exception {
//        log.info("文件上传开始");
//        //分片
//        response.setCharacterEncoding(utf8);//设置响应编码
//        Integer schunk = null;//当前分片
//        Integer schunks = null;//总分片
//        String name = null;//文件名
//        String uploadPath = "D:\\test\\extra";//临时存储文件路径
//        BufferedOutputStream bos = null;//文件合并的流
//        try {
//
//            DiskFileItemFactory factory = new DiskFileItemFactory();
//            factory.setSizeThreshold(1024);//设置缓冲区，不是直接写入磁盘，而是先缓冲到内存中，再写入磁盘
//            factory.setRepository(new File(uploadPath));//设置临时文件存储
//            ServletFileUpload upload = new ServletFileUpload((FileItemFactory) factory);
//            upload.setFileSizeMax(10241L * 10241 * 10241*51);
//            upload.setSizeMax(10241L * 10241 *10241 * 101);
//            List<FileItem> fileItems = upload.parseRequest((RequestContext) request);
//
//            for (FileItem fileItem : fileItems){
//                if (fileItem.isFormField()){
//                    if ("chunk".equals(fileItem.getFieldName())){
//                        schunk = Integer.parseInt(fileItem.getString(utf8));
//                    } else if ("chunks".equals(fileItem.getFieldName())){
//                        schunks = Integer.parseInt(fileItem.getString(utf8));
//                    } else if ("name".equals(fileItem.getFieldName())){
//                        name = fileItem.getString(utf8);
//                    }
//                }
//            }
//
//            for (FileItem fileItem : fileItems){
//                if (fileItem.isFormField()){
//                    if(name!=null){
//                        if (schunk !=null) {
//
//                        }
//                    }
//                }
//            }
//
//
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        } finally {
//            if (bos != null) {
//                try {
//                    bos.close();
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//        }
//
//
//        return "文件上传成功";
//    }
//
//
//}
